﻿function JumpPageAlbumList(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.AdvImage.FListAlbum.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divAlbumImagesList").innerHTML = retValue;
}
function JumpPageAlbumListDetails(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.AdvImage.AlbumDetails.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divViewAlbumListContent").innerHTML = retValue;
}
function JumpPageVideoDetail(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.FVideo.FListVideo.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divVideoContentListDetail").innerHTML = retValue;
}
function JumpPageAlbumList(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.AdvImage.FListAlbum.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divAlbumImagesList").innerHTML = retValue;
}
function JumpPageAlbumListDetails(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.AdvImage.AlbumDetails.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divViewAlbumListContent").innerHTML = retValue;
}
function JumpPageVideoDetail(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.FVideo.FListVideo.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divVideoContentListDetail").innerHTML = retValue;
}
function JumpPageAlbumList(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.AdvImage.FListAlbum.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divAlbumImagesList").innerHTML = retValue;
}
function JumpPageAlbumListDetails(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.AdvImage.AlbumDetails.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divViewAlbumListContent").innerHTML = retValue;
}
function JumpPageVideoDetail(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.FVideo.FListVideo.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divVideoContentListDetail").innerHTML = retValue;
}
function JumpPageAlbumList(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.AdvImage.FListAlbum.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divAlbumImagesList").innerHTML = retValue;
}
function JumpPageAlbumListDetails(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.AdvImage.AlbumDetails.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divViewAlbumListContent").innerHTML = retValue;
}
function JumpPageVideoDetail(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    retValue = SODC.CMPortal.FVideo.FListVideo.GetHtml(TabModuleId, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divVideoContentListDetail").innerHTML = retValue;
}

//For searchCrimePerson
function ClientDoSimpleSearch(LocationId, TabModuleId) {
    var Keyword = null;
    var HomeTown = null;
    var Age = 0;
    Keyword = document.getElementById("txtSearchKeyword").value;
    elem = document.getElementById("Notkey");
    if (document.getElementById("txt_hometown").value == '' || document.getElementById("txt_hometown").value.length < 1) {
        HomeTown = null;
    } else {
        HomeTown = document.getElementById("txt_hometown").value;
    }

    Age = getData();

    result = document.getElementById("ContentSearchResult");

    if (Keyword) {
        //RedValue = SODC.IDIS.Crime.FCrimeWP.GetResult(Keyword,LocationId).value;

        elem.innerHTML = "Kết quả tìm kiếm :"
        document.getElementById("divProcessingSearchResult").innerHTML = "";
        ps = null;
        result.innerHTML = IDIS.Crime.FCrimeWP.GetResult(TabModuleId, LocationId, Keyword, HomeTown, Age, 0, "JumpPageSearchResult", ps).value;

    } else {

        elem.innerHTML = "Chưa xác định được từ khóa tìm kiếm !!!";
        result.innerHTML = "";
    }

}
//For search Case
function ClientDoSimpleSearchCase(LocationId, TabModuleId) {
    var Keyword = null;
    var CrimeSubject = null;
    var Sentenced = 0;
    var CaseSubject = null;
    Keyword = document.getElementById("txtSearchKeyword").value;
    elem = document.getElementById("Notkey");
    if (document.getElementById("txt_toidanh").value == '' || document.getElementById("txt_toidanh").value.length < 1) {
        CrimeSubject = null;
    } else {
        CrimeSubject = document.getElementById("txt_toidanh").value;
    }
    if (document.getElementById("txt_tieude").value == '' || document.getElementById("txt_tieude").value.length < 1) {
        CaseSubject = null;
    } else {
        CaseSubject = document.getElementById("txt_tieude").value;
    }
    Sentenced = getDataSentenced();
    result = document.getElementById("ContentSearchResult");   
    if (Keyword) {
        //RedValue = SODC.IDIS.Crime.FCrimeWP.GetResult(Keyword,LocationId).value;

        elem.innerHTML = "Kết quả tìm kiếm :"
        document.getElementById("divProcessingSearchResult").innerHTML = "";
        ps = null;
        //result.innerHTML = IDIS.Crime.ListCrimeCase.GetResult(TabModuleId, LocationId, Keyword, HomeTown, Age, 0, "JumpPageSearchResult", ps).value;
        result.innerHTML = IDIS.Crime.ListCrimeCase.GetResult(TabModuleId, LocationId, Keyword, CrimeSubject, Sentenced,CaseSubject, 0, "JumpPageSearchResultCase", ps).value;

    } else {

        elem.innerHTML = "Chưa xác định được từ khóa tìm kiếm !!!";
        result.innerHTML = "";
    }

}
function getDataSentenced() {
    var em;
    em = document.getElementById("select_mucan");
    myData = em.options[em.options.selectedIndex].value;
    return myData;
}
function JumpPageSearchResultCase(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    document.getElementById("divProcessingSearchResult").innerHTML = SODC.IDIS.Crime.ListCrimeCase.GetProcessingText().value;
    setTimeout(RealJumpPageSearchResultCase(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript), 10);
}
function RealJumpPageSearchResultCase(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    PageIndex = CurrentPage;
    LocationId = document.getElementById("txt_LocationId").value;
    Keyword = document.getElementById("txtSearchKeyword").value;
    CrimeSubject = document.getElementById("txt_toidanh").value;
    CaseSubject = document.getElementById("txt_tieude").value;
    Sentenced = getDataSentenced();
    ps = null;
    retValue = SODC.IDIS.Crime.ListCrimeCase.GetResult(TabModuleId, LocationId, Keyword, CrimeSubject, Sentenced,CaseSubject, CurrentPage, JumpJavaScript, ps).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessingSearchResult").innerHTML = "";
    document.getElementById("ContentSearchResult").innerHTML = retValue;
}






function JumpPageSearchResult(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    document.getElementById("divProcessingSearchResult").innerHTML = SODC.IDIS.Crime.FCrimeWP.GetProcessingText().value;
    setTimeout(RealJumpPageSearchResult(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript), 10);
}
function RealJumpPageSearchResult(TabModuleId, MaxItems, ItemsPerRow, NoOfVisiblePage, CurrentPage, JumpJavaScript) {
    PageIndex = CurrentPage;
    LocationId = document.getElementById("txt_LocationId").value;
    Keyword = document.getElementById("txtSearchKeyword").value;
    HomeTown = document.getElementById("txt_hometown").value;
    Age = getData();
    ps = null;
    retValue = SODC.IDIS.Crime.FCrimeWP.GetResult(TabModuleId, LocationId, Keyword, HomeTown, Age, CurrentPage, JumpJavaScript, ps).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("divProcessingSearchResult").innerHTML = "";
    document.getElementById("ContentSearchResult").innerHTML = retValue;
}


function getData() {
    var em;
    em = document.getElementById("select_age");
    myData = em.options[em.options.selectedIndex].value;
    return myData;
}

// AddNewCrime

function ClientResetAllFieldCrime() {
    document.getElementById("drcngaynhan").value = '';
    document.getElementById("drcfullname").value = '';
    $("#drcrbtmale").attr('checked', true);
    document.getElementById("drcbirthdate").value = '';
    document.getElementById("drcCMT").value = '';
    document.getElementById("drcngaycap").value = '';
    document.getElementById("drcnoicap").value = '';
    document.getElementById("drcnguyenquan").value = '';
    document.getElementById("drcchoohn").value = '';
    document.getElementById("drctendaithe").value = '';
    document.getElementById("drcnoidk").value = '';
    $("#drckotongiao").attr('checked', true);
    document.getElementById("drccheckdangvien").checked = false;
    document.getElementById("drcchecktienan").checked = false;
    document.getElementById("drccheckxuphat").checked = false;
    $("#drcrbtkinh").attr('checked', true);
    $("#drcvietnam").attr('checked', true);
    document.getElementById("drcdangvien").checked = false;
    document.getElementById("drcthanhphan").selectedIndex = 0;
    document.getElementById("drcvieclam").selectedIndex = 0;
    /* document.getElementById("drctrangthai").selectedIndex = 0;
    document.getElementById("drchinhthuccn").selectedIndex = 0;
    document.getElementById("drcnoicainghien").value = "";
    document.getElementById("drcbienphap").selectedIndex = 0;

    $("#drcchuacainghien").attr('checked', true);
    $("#drctainoicutru").attr('checked', true);
    document.getElementById("drchotrosaucn").selectedIndex = 0;
    document.getElementById("drcbatdaunghien").value = '';
    document.getElementById("drcloaimtsd").selectedIndex = 0;
    document.getElementById("drcquatrinhxd").value = '';*/
    document.getElementById("drcfullname").focus();
}


function checkdate(date) {
    var validformat = /^\d{2}\/\d{2}\/\d{4}$/;
    var returnval = false;
    if (!validformat.test(date)) {
        alert("Nhập sai định dạng ngày.");
    }
    else {
        var monthfield = date.split("/")[0];
        var dayfield = date.split("/")[1];
        var yearfield = date.split("/")[2];
        var dayobj = new Date(yearfield, monthfield - 1, dayfield);
        if ((dayobj.getMonth() + 1 != monthfield) || (dayobj.getDate() != dayfield) || (dayobj.getFullYear() != yearfield)) {
            alert("Nhập theo định dạng tháng/ngày/năm.");
        }
        else {
            returnval = true;
        }
    }
    return returnval;
}

var mavuan, ngayvuan, ngayxetxu, heroin, thuocphien, matuyth_g, matuyth_ml, gaynghien_v, gaynghien_l, huongthan_v, huongthan_l, tienchat_l, tienchat_kg, matuykhac_g, matuykhac_ml, cansa, vnd, ngoaite, kimkhi, tskhac, vukhi, hungkhi, vuan;

function ClientSideCheckValidate() {
    ngaynhan = document.getElementById("drcngaynhan").value;
    if (ngaynhan == "") {
        alert("Chưa nhập ngày nhận!");
        document.getElementById("drcngaynhan").focus();
        return;
    }
    checkngaynhan = checkdate(ngaynhan);
    if (checkngaynhan == false) {
        document.getElementById("drcngaynhan").focus();
        document.getElementById("drcngaynhan").select();
        return;
    }
    fullname = document.getElementById("drcfullname").value;
    if (fullname == "") {
        alert("Nhập họ tên đầy đủ!");
        document.getElementById("drcfullname").focus();
        return;
    }
    checksex = $('input[name=rbtchecksex]:checked').val();
    birthdate = document.getElementById("drcbirthdate").value;
    if (birthdate == "") {
        alert("Nhập ngày sinh!");
        document.getElementById("drcbirthdate").focus();
        return;
    }
    checkbirthdate = checkdate(birthdate);
    if (checkbirthdate == false) {

        document.getElementById("drcbirthdate").select();
        return;
    }
    cmt = document.getElementById("drcCMT").value;
    //    if (cmt != "") {
    //        var year = /^[0-9]$/;
    //        if (year.test(cmt) == false) {
    //            alert("Nh?p sai d?nh d?ng s? ch?ng minh thu!");
    //            document.getElementById("drcCMT").select();
    //            return;
    //        }  
    //    }
    ngaycap = document.getElementById("drcngaycap").value;
    noicap = document.getElementById("drcnoicap").value;
    nguyenquan = document.getElementById("drcnguyenquan").value;
    if (nguyenquan == "") {
        alert("Nhập nguyên quán!");
        document.getElementById("drcnguyenquan").focus();
        return;
    }
    choohn = document.getElementById("drcchoohn").value;
    if (choohn == "") {
        alert("Nhập chỗ ở hiện nay!");
        document.getElementById("drcchoohn").focus();
        return;
    }
    tendaithe = document.getElementById("drctendaithe").value;
    noidk = document.getElementById("drcnoidk").value;
    if (noidk == "") {
        alert("Nhập hộ khẩu thường trú!");
        document.getElementById("drcnoidk").focus();
        return;
    }
    tongiao = $('input[name=drctongiao]:checked').val();
    condangvien = document.getElementById("drccheckdangvien").checked;
    tienan = document.getElementById("drcchecktienan").checked;
    xuphat = document.getElementById("drccheckxuphat").checked;
    //right col
    checkdantoc = $('input[name=drcdantoc]:checked').val();
    checkquoctich = $('input[name=drcquoctich]:checked').val();
    checkdangvien = document.getElementById("drcdangvien").checked;
    thanhphan = document.getElementById("drcthanhphan").options[document.getElementById("drcthanhphan").selectedIndex].value;
    vieclam = document.getElementById("drcvieclam").options[document.getElementById("drcvieclam").selectedIndex].value;
    CaseId = document.getElementById("txt_mavuan").value;
    var mucan = getData_mucan();
    getData_toidanh();
    toidanh = $("#txt_toidanh").val();
    var nam = document.getElementById("txt_nam").value;
    var thang = document.getElementById("txt_thang").value;
    var ngaythihanh = document.getElementById("txt_ngayxetxu").value;
    if (CaseId != "") {
        if (IDIS.Crime.AddNewCrime.CheckexitCase(CaseId).value == true) {
            /* Insert Crime ,CaseStatus  :*/
            retVal = IDIS.Crime.AddNewCrime.ServerSideAddNewCrime(ngaynhan, fullname, checksex, birthdate, cmt, ngaycap, noicap, nguyenquan,
																choohn, tendaithe, noidk, tongiao, condangvien, tienan, xuphat, checkdantoc,
																checkquoctich, checkdangvien, CaseId, thanhphan, vieclam, mucan, toidanh, nam,
																thang, ngaythihanh).value;
            if (retVal.indexOf("ERROR") != -1) {             
                alert(retVal);
                return;
            } else {
                ClientResetAllFieldCrime();
                alert("Thêm mới thông tin tội phạm thành công !");
            }
        } else {
            mavuan = document.getElementById("txt_mavuan").value;
            if (mavuan == "") {
                alert("Nhập mã vụ án!!!");
                document.getElementById("txt_mavuan").select();
                return;
            }


            ngayvuan = $("#txt_ngayvuan").val();
            if (ngayvuan == "") {
                alert("Chưa nhập ngày vụ án");
                document.getElementById("txt_ngayvuan").select();
                return;
            }

            ngayxetxu = $("#txt_ngayxetxu").val();
            if (checkdate(ngayxetxu) == false) {
                alert("Chưa nhập ngày xét xử");
                document.getElementById("txt_ngayxetxu").select();
                return;
            }

            heroin = $("#txt_heroin").val();
            if (heroin != "") {
                if (isNaN(heroin) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_heroin").select();
                    return;
                }
            }
            thuocphien = $("#txt_thuocphien").val();
            if (thuocphien != "") {
                if (isNaN(thuocphien) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_thuocphien").select();
                    return;
                }
            }
            matuyth_g = $("#txt_matuyth_g").val();
            if (matuyth_g != "") {
                if (isNaN(matuyth_g) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_matuyth_g").select();
                    return;
                }
            }
            matuyth_ml = $("#txt_matuyth_ml").val();
            if (matuyth_ml != "") {
                if (isNaN(matuyth_ml) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_matuyth_ml").select();
                    return;
                }
            }

            gaynghien_v = $("#txt_gaynghien_v").val();
            if (gaynghien_v != "") {
                if (isNaN(gaynghien_v) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_gaynghien_v").select();
                    return;
                }
            }
            gaynghien_l = $("#txt_gaynghien_l").val();
            if (gaynghien_l != "") {
                if (isNaN(gaynghien_l) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_gaynghien_l").select();
                    return;
                }
            }
            huongthan_v = $("#txt_huongthan_v").val();
            if (huongthan_v != "") {
                if (isNaN(huongthan_v) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_huongthan_v").select();
                    return;
                }
            }


            huongthan_l = $("#txt_huongthan_l").val();
            if (huongthan_l != "") {
                if (isNaN(huongthan_l) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_huongthan_l").select();
                    return;
                }
            }
            tienchat_l = $("#txt_tienchat_l").val();
            if (tienchat_l != "") {
                if (isNaN(tienchat_l) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_tienchat_l").select();
                }
            }
            tienchat_kg = $("#txt_tienchat_kg").val();
            if (tienchat_kg != "") {
                if (isNaN(tienchat_kg) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_tienchat_kg").select();
                }
            }
            matuykhac_g = $("#txt_matuykhac_g").val();
            if (matuykhac_ml != "") {
                if (isNaN(matuykhac_g) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_matuykhac_g").select();
                }
            }
            matuykhac_ml = $("#txt_matuykhac_ml").val();
            if (matuykhac_ml != "") {
                if (isNaN(matuykhac_ml) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_matuykhac_ml").select();
                }
            }
            cansa = $("#txt_cansa").val();
            if (cansa != "") {
                if (isNaN(cansa) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_cansa").select();
                }
            }
            vnd = $("#txt_vnd").val();
            if (vnd != "") {
                if (isNaN(vnd) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_vnd").select();
                }
            }
            ngoaite = $("#txt_ngoaite").val();
            if (ngoaite != "") {
                if (isNaN(ngoaite) == true) {
                    alert("Yêu cầu nhập số!");
                    document.getElementById("txt_ngoaite").select();
                }
            }
            kimkhi = $("#txt_kimkhi").val();
            tskhac = $("#txt_tskhac").val();
            vukhi = $("#txt_vukhi").val();
            hungkhi = $("#txt_hungkhi").val();
            // var mucan = getData_mucan();
            // getData_toidanh();
            // toidanh = $("#txt_toidanh").val();
            vuan = $("#txt_tieude").val();
            if (vuan == "") {
                alert("Nhập tiêu vụ án!!!");
                document.getElementById("txt_tieude").focus();
                return;
            }
            /* Insert Crime ,Case and CaseStatus:*/    
            retVal = IDIS.Crime.AddNewCrime.ServerSideAddNewCrimeCaseStatus(ngaynhan, fullname, checksex, birthdate, cmt, ngaycap, noicap, nguyenquan,
																choohn, tendaithe, noidk, tongiao, condangvien, tienan, xuphat, checkdantoc,
																checkquoctich, checkdangvien, CaseId, thanhphan, vieclam, mucan, toidanh, nam,
																thang, ngaythihanh, vuan, ngayvuan, heroin, thuocphien, matuyth_ml, matuyth_g,
                                                                gaynghien_v, gaynghien_l, huongthan_v, huongthan_l, tienchat_kg, tienchat_l,
                                                                matuykhac_g, matuykhac_ml, cansa, vnd, ngoaite, kimkhi, tskhac, vukhi, hungkhi).value;
            if (retVal.indexOf("ERROR") != -1) {
                alert(retVal);
                return;
            } else {              
                alert("Thêm mới thông tin tội phạm và vụ án thành công !");
                ClientResetAllFieldCrime();
                ResetAllFieldCase();
            }
            //retVal1 = IDIS.Crime.AddNewCrime.ServerSideAddNewCaseStatus(retVal, CaseId, thanhphan, vieclam, mucan, toidanh, nam, thang, ngaythihanh).value;
        }
    } else {
        alert("Yêu cầu nhập thông tin vụ án cho đối tượng!");
    }
}


$(document).ready(function () {
    $(".btn_inscaseinfo").colorbox({ width: "80%", height: "80%", inline: true, href: "#insnewcasepanel" });
});



//function ClientSideGetCaseInfo(mavuan, ngayvuan, ngayxetxu, heroin, thuocphien, matuyth_g, matuyth_ml, gaynghien_v, gaynghien_l,
//huongthan_v, huongthan_l, tienchat_l, tienchat_kg, matuykhac_g, matuykhac_ml, cansa, vnd, ngoaite, kimkhi, tskhac, vukhi, hungkhi, vuan)  {
function ClientSideGetCaseInfo() {
    mavuan = document.getElementById("txt_mavuan").value;
    if (mavuan == "") {
        alert("Nhập mã vụ án!!!");
        document.getElementById("txt_mavuan").focus();
        return;
    }
    ngayvuan = $("#txt_ngayvuan").val();
    if (ngayvuan == "") {
        alert("Nhập ngày vụ án");
        document.getElementById("txt_ngayvuan").focus();
        return;
    }

    ngayxetxu = $("#txt_ngayxetxu").val();
    if (checkdate(ngayxetxu) == false) {
        document.getElementById("txt_ngayxetxu").select();
        return;
    }

    heroin = $("#txt_heroin").val();
    if (heroin != "") {
        if (isNaN(heroin) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_heroin").focus();
            return;
        }
    }
    thuocphien = $("#txt_thuocphien").val();
    if (thuocphien != "") {
        if (isNaN(thuocphien) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_thuocphien").focus();
            return;
        }
    }
    matuyth_g = $("#txt_matuyth_g").val();
    if (matuyth_g != "") {
        if (isNaN(matuyth_g) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_matuyth_g").focus();
            return;
        }
    }
    matuyth_ml = $("#txt_matuyth_ml").val();
    if (matuyth_ml != "") {
        if (isNaN(matuyth_ml) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_matuyth_g").focus();
            return;
        }
    }

    gaynghien_v = $("#txt_gaynghien_v").val();
    if (gaynghien_v != "") {
        if (isNaN(gaynghien_v) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_gaynghien_v").focus();
            return;
        }
    }
    gaynghien_l = $("#txt_gaynghien_l").val();
    if (gaynghien_l != "") {
        if (isNaN(gaynghien_l) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_gaynghien_l").focus();
            return;
        }
    }
    huongthan_v = $("#txt_huongthan_v").val();
    if (huongthan_v != "") {
        if (isNaN(huongthan_v) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_huongthan_v").focus();
            return;
        }
    }


    huongthan_l = $("#txt_huongthan_l").val();
    if (huongthan_l != "") {
        if (isNaN(huongthan_l) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_huongthan_l").focus();
            return;
        }
    }
    tienchat_l = $("#txt_tienchat_l").val();
    if (tienchat_l != "") {
        if (isNaN(tienchat_l) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_tienchat_l").focus();
        }
    }
    tienchat_kg = $("#txt_tienchat_kg").val();
    if (tienchat_kg != "") {
        if (isNaN(tienchat_kg) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_tienchat_kg").focus();
        }
    }
    matuykhac_g = $("#txt_matuykhac_g").val();
    if (matuykhac_ml != "") {
        if (isNaN(matuykhac_g) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_matuykhac_g").focus();
        }
    }
    matuykhac_ml = $("#txt_matuykhac_ml").val();
    if (matuykhac_ml != "") {
        if (isNaN(matuykhac_ml) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_matuykhac_ml").focus();
        }
    }
    cansa = $("#txt_cansa").val();
    if (cansa != "") {
        if (isNaN(cansa) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_cansa").focus();
        }
    }
    vnd = $("#txt_vnd").val();
    if (vnd != "") {
        if (isNaN(vnd) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_vnd").focus();
        }
    }
    ngoaite = "1"; // $("#txt_ngoaite").val();
    //if (ngoaite != "") {
    //   if (isNaN(ngoaite) == true) {
    //    alert("Yêu cầu nhập số!");
    //  document.getElementById("txt_ngoaite").focus();
    //}
    //}
    kimkhi = $("#txt_kimkhi").val();
    tskhac = $("#txt_tskhac").val();
    vukhi = $("#txt_vukhi").val();
    hungkhi = $("#txt_hungkhi").val();
    var mucan = getData_mucan();
    getData_toidanh();
    toidanh = $("#txt_toidanh").val();
    vuan = $("#txt_tieude").val();
    if (vuan == "") {
        alert("Nhập tiêu vụ án!!!");
        document.getElementById("txt_tieude").focus();
        return;
    }
    // var nam = document.getElementById("txt_nam").value();
    // var thang = document.getElementById("txt_thang").value();
    //retVal = IDIS.Crime.AddNewCrime.ServerSideAddNewCase(mavuan, vuan, ngayvuan, heroin, thuocphien, matuyth_ml, matuyth_g, gaynghien_v, gaynghien_l, huongthan_v, huongthan_l, tienchat_kg, tienchat_l, matuykhac_g, matuykhac_ml, cansa, vnd, ngoaite, kimkhi, tskhac, vukhi, hungkhi).value;
}


/*$(document).ready(function () {
$("#ContentAddCase").click(function () {
if ($("#insnewcasepanel").is(":hidden")) {
$("#insnewcasepanel").slideDown("slow");
$("#insnewcasepanel").show();
//            $("#contactLink").hide();

}
//        else {
//            $("#contactForm").slideUp("slow");
//            $("#contactLink").show();
//        }
});
});*/




function getData_mucan() {
    var em;
    em = document.getElementById("sl_mucan");
    myData = em.options[em.options.selectedIndex].value;
    return myData;
}


/* function getSelected(opt) {
var selected = new Array();
var index = 0;
for (var intLoop=0; intLoop < opt.length; intLoop++) {
if (opt[intLoop].selected) {
index = selected.length;
selected[index] = new Object;
selected[index].value = opt[intLoop].value;
selected[index].index = intLoop;
}
}
return selected;
}*/


function getData_toidanh() {
    var abc;
    var text = document.getElementById("txt_toidanh");
    abc = document.getElementById("sl_toidanh");
    for (var idx = abc.options.length - 1; idx >= 0; idx--) {
        if (abc.options[idx].selected == true) {
            text.value = abc.options[idx].value;
        }
    }

}


function ResetAllFieldCase() {
    
    document.getElementById("txt_mavuan").value = '';
    document.getElementById("txt_ngayvuan").value = '';
    document.getElementById("txt_tieude").value = '';
    document.getElementById("txt_ngayxetxu").value = '';
  
    document.getElementById("txt_heroin").value = '0';
    document.getElementById("txt_thuocphien").value = '0';
    document.getElementById("txt_matuyth_g").value = '0';
    document.getElementById("txt_matuyth_ml").value = '0';
    document.getElementById("txt_gaynghien_v").value = '0';
    document.getElementById("txt_gaynghien_l").value = '0';
    document.getElementById("txt_huongthan_v").value = '0';
    document.getElementById("txt_huongthan_l").value = '0';
    document.getElementById("txt_tienchat_l").value = '0';
    document.getElementById("txt_tienchat_kg").value = '0';
    document.getElementById("txt_matuykhac_g").value = '0';
    document.getElementById("txt_matuykhac_ml").value = '0';
    document.getElementById("txt_cansa").value = '0';
    document.getElementById("txt_vnd").value = '0';
    document.getElementById("txt_ngoaite").value = '0';
    document.getElementById("txt_kimkhi").value = '0';
    document.getElementById("txt_tskhac").value = '0';
    document.getElementById("txt_vukhi").value = '0';
    document.getElementById("txt_hungkhi").value = '0';
    document.getElementById("txt_nam").value = '0';
    document.getElementById("txt_thang").value = '0';
    //var mucan = getData_mucan();

    //getData_toidanh();
    //var toidanh = new [];
    //toidanh = document.getElementById("txt_toidanh").value();
}


function SearchCaseById() {
    var Keyword = null;
    //Result = document.getElementById("ContentAddCase");
    em = document.getElementById("ClientRenderCaseInfomationZone");
    
    Keyword = document.getElementById("txt_mavuan").value;
    if (Keyword != "")
    //retValue = IDIS.Crime.AddNewCrime.ClientRenderCaseInfomationZone(Keyword).value;
    //Result.innerHTML = redValue;
    {
        checkCase = IDIS.Crime.AddNewCrime.CheckexitCase(Keyword).value;
        if (checkCase == false) {
            alert("Vụ án này không tồn tại hoặc đã bị xóa,xin kiểm tra lại!!!");
        } else {
            em.innerHTML = "";
            retValue = IDIS.Crime.AddNewCrime.ClientRenderCaseInfomationZone(Keyword).value;
            em.innerHTML = retValue;
        }
    }
    else {
        alert("Nhập mã vụ án!!!!")
        //nk.innerHTML = "";
    }
}

function SearchCaseById1() {
    var Keyword = null;
    //Result = document.getElementById("ContentAddCase");
    em = document.getElementById("ClientRenderCaseInfomationZone");
    Keyword = document.getElementById("txt_caseid").value;
    if (Keyword != "")
    //retValue = IDIS.Crime.AddNewCrime.ClientRenderCaseInfomationZone(Keyword).value;
    //Result.innerHTML = redValue;
    {
        checkCase = IDIS.Crime.FCrimeEditWP.CheckexitCase(Keyword).value;
        if(checkCase == false) {
            alert("Vụ án này không tồn tại hoặc đã bị xóa,xin kiểm tra lại!!!");
        } else {
            em.innerHTML = "";
            retValue = IDIS.Crime.FCrimeEditWP.ClientRenderCaseInfomationZone(Keyword).value;
            em.innerHTML = retValue;
        }
    }
    else {
        alert("Nhập mã vụ án!!!!")
        //nk.innerHTML = "";
    }
}


function SearchCaseByIdForUpdate(CaseId) {
    //var Keyword = null;
    //Result = document.getElementById("ContentAddCase");
    ShowFormInputCase();
    em = document.getElementById("ClientRenderCaseInfomationZone");
    Show = document.getElementById("ClientRenderCaseCodeZone");
    Show.style.display = "none";  
 
        retValue = IDIS.Crime.FCrimeEditWP.ClientRenderCaseInfomationZone(CaseId).value;
        em.innerHTML = retValue;

}

function ShowFormInputCase() {
   
    em = document.getElementById("ContentAddCase");
    if (em.style.display == "block")
        em.style.display = "none";
    else {
        em.style.display = "block";
        //CaseId = document.getElementById("txt_mavuan").value;
        Show = document.getElementById("ClientRenderCaseCodeZone");
        Show.style.display = "block";      
    }

}

function CloseFormInputCase() {
    var em;
    em = document.getElementById("insnewcasepanel");

    em.style.display = 'none';
}
function ClientAddHtml() {
    belongSite = document.getElementById("drpSelectSite").options[document.getElementById("drpSelectSite").selectedIndex].value;
    Url = SharepointPortal.WebParts.Html.Html.GetAddNewUrl(belongSite).value;
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 840px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    WorkflowStatusIndex = document.getElementById("divSelectWorkflowStatus").selectedIndex;
    WorkflowStatus = document.getElementById("divSelectWorkflowStatus").options[WorkflowStatusIndex].value;
    PageIndex = document.getElementById("divSelectPage").selectedIndex;
    value = SharepointPortal.WebParts.Html.Html.GetHtml(WorkflowStatus, PageIndex).value;
    if (value.indexOf("ERROR") == -1) {
        document.getElementById("divHtmlContent").innerHTML = value;
    }
    else {
        alert(value);
    }
}

function ClientSaveAddHtml() {
    belongSite = document.getElementById("txtBelongSite").value;
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    Alias = document.getElementById("txtAlias").value;
    Subject = document.getElementById("txtSubject").value;
    var instanceName = "ctl04";
    var oEditor = FCKeditorAPI.GetInstance(instanceName);
    bodyText = oEditor.GetXHTML(true);
    value = SharepointPortal.WebParts.Html.AddHtml.ServerSideAddHtml(belongSite, language, Alias, Subject, bodyText).value;
    if (value.indexOf("ERROR") != -1) {
        alert(value);
        return;
    }
    window.close();
}

function ClientSaveHtml(HtmlId) {
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    Alias = document.getElementById("txtAlias").value;
    Subject = document.getElementById("txtSubject").value;
    if (FCKeditorAPI == null) {

        alert(SharepointPortal.WebParts.Html.UpdateHtml.GetLoadDataMsg().value);
        return;
    }
    var instanceName = "ctl04";
    var oEditor = FCKeditorAPI.GetInstance(instanceName);

    if (oEditor == null) {
        alert(SharepointPortal.WebParts.Html.UpdateHtml.GetLoadDataMsg().value);
        return;
    }
    bodyText = oEditor.GetXHTML(true);
    value = SharepointPortal.WebParts.Html.UpdateHtml.ServerSideHtml(language, HtmlId, Alias, Subject, bodyText).value;
    if (value.indexOf("ERROR") != -1) {
        alert(value);
        return;
    }
    retValue = SharepointPortal.WebParts.Html.UpdateHtml.GetInfoSaveMsg(language).value;
    alert(retValue);
    window.close();
}

function RunFilter() {
    document.getElementById("divProcessing").innerHTML = SharepointPortal.WebParts.Html.Html.GetProcessingText().value;
    setTimeout("RealRunFilter()", 10);
}


function RealRunFilter() {
    WorkflowStatusIndex = document.getElementById("divSelectWorkflowStatus").selectedIndex;
    WorkflowStatus = "";
    if (WorkflowStatusIndex != -1) {
        WorkflowStatus = document.getElementById("divSelectWorkflowStatus").options[WorkflowStatusIndex].value;
    }

    belongSite = document.getElementById("drpSelectSite").options[document.getElementById("drpSelectSite").selectedIndex].value;
    PageIndex = document.getElementById("divSelectPage").selectedIndex;
    if (PageIndex < 0) PageIndex = 0;
    value = SharepointPortal.WebParts.Html.Html.GetHtml(belongSite, WorkflowStatus, PageIndex).value;
    if (value.indexOf("ERROR") != -1) {
        document.getElementById("divProcessing").innerHTML = "";
        alert(value);
        return;
    }
    document.getElementById("divProcessing").innerHTML = "";
    document.getElementById("divHtmlContent").innerHTML = value;
}


function ClientDeleteHtml(HtmlId) {
    if (confirm(SharepointPortal.WebParts.Html.Html.GetConfirmMsg().value) == false) {
        return;
    }
    value = SharepointPortal.WebParts.Html.Html.ServerSideDeleteHtml(HtmlId).value;
    if (value.indexOf("ERROR") != -1) {
        alert(value);
        return;
    }
    alert(SharepointPortal.WebParts.Html.Html.GetDeleteOkMsg().value);
    WorkflowStatusIndex = document.getElementById("divSelectWorkflowStatus").selectedIndex;
    WorkflowStatus = document.getElementById("divSelectWorkflowStatus").options[WorkflowStatusIndex].value;
    PageIndex = document.getElementById("divSelectPage").selectedIndex;
    value = SharepointPortal.WebParts.Html.Html.GetHtml(WorkflowStatus, PageIndex).value;
    document.getElementById("divHtmlContent").innerHTML = value;
}

function ShowUpdateHtmlForm(HtmlId) {
    Url = SharepointPortal.WebParts.Html.Html.GetUpdateHtmlUrl(HtmlId).value;
    window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 840px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    WorkflowStatusIndex = document.getElementById("divSelectWorkflowStatus").selectedIndex;
    WorkflowStatus = document.getElementById("divSelectWorkflowStatus").options[WorkflowStatusIndex].value;
    PageIndex = document.getElementById("divSelectPage").selectedIndex;

    value = SharepointPortal.WebParts.Html.Html.GetHtml(WorkflowStatus, PageIndex).value;
    if (value.indexOf("ERROR") == -1) {
        document.getElementById("divHtmlContent").innerHTML = value;
    }
    else {
        alert(value);
    }
}


function DetectHtmlBody(HtmlId) {
    language = document.getElementById("divSelectLanguage").options[document.getElementById("divSelectLanguage").selectedIndex].value;
    retValue = SharepointPortal.WebParts.Html.UpdateHtml.GetSubject(language, HtmlId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    document.getElementById("txtSubject").value = retValue;

    var instanceName = "ctl02";
    var oEditor = FCKeditorAPI.GetInstance(instanceName);
    retValue = SharepointPortal.WebParts.Html.UpdateHtml.GetBody(language, HtmlId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    oEditor.SetHTML(retValue);

}


function ClientPublishingHtml(HtmlId) {
    if (confirm(SharepointPortal.WebParts.Html.Html.GetConfirmPublishingMsg().value) == false) {
        return;
    }
    retValue = SharepointPortal.WebParts.Html.Html.ServerSidePublishing(HtmlId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    alert(retValue);
}




function ClientUnPublishingHtml(HtmlId) {
    if (confirm(SharepointPortal.WebParts.Html.Html.GetConfirmUnPublishingMsg().value) == false) {
        return;
    }
    retValue = SharepointPortal.WebParts.Html.Html.ServerSideUnPublishing(HtmlId).value;
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    alert(retValue);
}

function DoSyncAll(belongSite) {
    if (confirm(SharepointPortal.WebParts.Html.Html.GetConfirmSyncAllMsg().value) == false) {
        return;
    }
    document.getElementById("divProcessing").innerHTML = SharepointPortal.WebParts.Html.Html.GetProcessingText().value;
    setTimeout("RealDoSyncAll('" + belongSite + "')", 10);
}



function RealDoSyncAll(belongSite) {
    retValue = SharepointPortal.WebParts.Html.Html.SyncToServer(belongSite).value;
    document.getElementById("divProcessing").innerHTML = "";
    alert(retValue);
}


function ClientSideCheckUpdateCrime(CrimeId) {
    //ngaynhan = document.getElementById("upngaynhan").value;
    /*if (ngaynhan == "") {
    alert("Chưa nhập ngày nhận!");
    document.getElementById("upngaynhan").focus();
    return;
    }
    checkngaynhan = checkdate(ngaynhan);
    if (checkngaynhan == false) {
    document.getElementById("upngaynhan").focus();
    document.getElementById("upngaynhan").select();
    return;
    }*/
    fullname = document.getElementById("drcfullname").value;
    if (fullname == "") {
        alert("Chưa nhập họ tên tội phạm!");
        document.getElementById("drcfullname").focus();
        return;
    }
    checksex = $('input[name=rbtchecksex]:checked').val();
    birthdate = document.getElementById("drcbirthdate").value;
    if (birthdate == "") {
        alert("Chưa nhập ngày sinh tội phạm!");
        document.getElementById("drcbirthdate").focus();
        return;
    }
    checkbirthdate = checkdate(birthdate);
    if (checkbirthdate == false) {

        document.getElementById("drcbirthdate").select();
        return;
    }
    cmt = document.getElementById("drcCMT").value;
    if (cmt != "") {
        var year = /^[0-9]+$/;
        if (year.test(cmt) == false) {
            alert("Nhập sai định dạng số chứng minh thư!");
            document.getElementById("drcCMT").select();
            return;
        }
    }
    ngaycap = document.getElementById("drcngaycap").value;
    noicap = document.getElementById("drcnoicap").value;
    nguyenquan = document.getElementById("drcnguyenquan").value;
    if (nguyenquan == "") {
        alert("Chưa nhập nguyên quán tội phạm!");
        document.getElementById("drcnguyenquan").focus();
        return;
    }
    noidk = document.getElementById("drcnoidk").value;
    if (noidk == "") {
        alert("Chưa nhập nơi đăng ký hộ khẩu thường trú của tội phạm!");
        document.getElementById("drcnoidk").focus();
        return;
    }
    choohn = document.getElementById("drcchoohn").value;
    tendaithe = document.getElementById("drctendaithe").value;

    tongiao = $('input[name=drcdantoc]:checked').val();
    condangvien = document.getElementById("drccheckdangvien").checked;
    tienan = document.getElementById("drcchecktienan").checked;
    xdrchat = document.getElementById("drccheckxuphat").checked;
    //right col
    checkdantoc = $('input[name=drcdantoc]:checked').val();
    checkquoctich = $('input[name=drcquoctich]:checked').val();
    checkdangvien = document.getElementById("drcdangvien").checked;

    retVal = IDIS.Crime.FCrimeEditWP.ServerSideUpdateCrime(CrimeId, fullname, checksex, birthdate, cmt, ngaycap, noicap, nguyenquan, choohn, tendaithe, noidk, tongiao, condangvien, tienan, xdrchat, checkdantoc, checkquoctich, checkdangvien).value;
    if (retVal.indexOf("ERROR") != -1) {
        alert(retVal);
        return;
    }
    alert(retVal);

}

function DeleteCrimeStatus(StatusId) {
    Msg = IDIS.Crime.FCrimeEditWP.GetConfirmDeleteMsg().value;
    if (confirm(Msg) == false) return;
    retVal = IDIS.Crime.FCrimeEditWP.ServerSideDeleteCrimeCaseStatus(StatusId).value;
    if (retVal.indexOf("ERROR") != -1) {
        alert(retVal);
        return;
    }
    alert(retVal);
}


function ClientSideUpdateCase(CaseId,CrimeId) {
    mavuan = document.getElementById("txt_caseid").value;
    /*if (mavuan == "") {
        alert("Nhập mã vụ án!!!");
        document.getElementById("txt_mavuan").focus();
        return;
    }*/
    ngayvuan = $("#txt_ngayvuan").val();
    if (ngayvuan == "") {
        alert("Nhập ngày vụ án");
        document.getElementById("txt_ngayvuan").focus();
        return;
    }

    ngayxetxu = $("#txt_ngayxetxu").val();
    if (ngayxetxu == "") {
        document.getElementById("txt_ngayxetxu").select();
        return;
    }

    heroin = $("#txt_heroin").val();
    if (heroin != "") {
        if (isNaN(heroin) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_heroin").focus();
            return;
        }
    }
    thuocphien = $("#txt_thuocphien").val();
    if (thuocphien != "") {
        if (isNaN(thuocphien) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_thuocphien").focus();
            return;
        }
    }
    matuyth_g = $("#txt_matuyth_g").val();
    if (matuyth_g != "") {
        if (isNaN(matuyth_g) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_matuyth_g").focus();
            return;
        }
    }
    matuyth_ml = $("#txt_matuyth_ml").val();
    if (matuyth_ml != "") {
        if (isNaN(matuyth_ml) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_matuyth_g").focus();
            return;
        }
    }

    gaynghien_v = $("#txt_gaynghien_v").val();
    if (gaynghien_v != "") {
        if (isNaN(gaynghien_v) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_gaynghien_v").focus();
            return;
        }
    }
    gaynghien_l = $("#txt_gaynghien_l").val();
    if (gaynghien_l != "") {
        if (isNaN(gaynghien_l) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_gaynghien_l").focus();
            return;
        }
    }
    huongthan_v = $("#txt_huongthan_v").val();
    if (huongthan_v != "") {
        if (isNaN(huongthan_v) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_huongthan_v").focus();
            return;
        }
    }


    huongthan_l = $("#txt_huongthan_l").val();
    if (huongthan_l != "") {
        if (isNaN(huongthan_l) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_huongthan_l").focus();
            return;
        }
    }
    tienchat_l = $("#txt_tienchat_l").val();
    if (tienchat_l != "") {
        if (isNaN(tienchat_l) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_tienchat_l").focus();
        }
    }
    tienchat_kg = $("#txt_tienchat_kg").val();
    if (tienchat_kg != "") {
        if (isNaN(tienchat_kg) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_tienchat_kg").focus();
        }
    }
    matuykhac_g = $("#txt_matuykhac_g").val();
    if (matuykhac_ml != "") {
        if (isNaN(matuykhac_g) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_matuykhac_g").focus();
        }
    }
    matuykhac_ml = $("#txt_matuykhac_ml").val();
    if (matuykhac_ml != "") {
        if (isNaN(matuykhac_ml) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_matuykhac_ml").focus();
        }
    }
    cansa = $("#txt_cansa").val();
    if (cansa != "") {
        if (isNaN(cansa) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_cansa").focus();
        }
    }
    vnd = $("#txt_vnd").val();
    if (vnd != "") {
        if (isNaN(vnd) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_vnd").focus();
        }
    }
    ngoaite = $("#txt_ngoaite").val();
    if (ngoaite != "") {
       if (isNaN(ngoaite) == true) {
            alert("Yêu cầu nhập số!");
            document.getElementById("txt_ngoaite").focus();
        }
    }
    kimkhi = $("#txt_kimkhi").val();
    tskhac = $("#txt_tskhac").val();
    vukhi = $("#txt_vukhi").val();
    hungkhi = $("#txt_hungkhi").val();
    mucan = getData_mucan();
    getData_toidanh();
    toidanh = $("#txt_toidanh").val();
    vuan = $("#txt_tieude").val();
    if (vuan == "") {
        alert("Nhập tiêu vụ án!!!");
        document.getElementById("txt_tieude").focus();
        return;
    }
    nam = $("#txt_nam").val();
    thang = $("#txt_thang").val();
    thanhphan = document.getElementById("drcthanhphan").options[document.getElementById("drcthanhphan").selectedIndex].value;
    vieclam = document.getElementById("drcvieclam").options[document.getElementById("drcvieclam").selectedIndex].value;
    //alert(vuan);
    if (CaseId != "") {      
        retValue = IDIS.Crime.FCrimeEditWP.ServerSideUpdateCase(CaseId, vuan, ngayvuan, heroin, cansa, matuyth_g, matuyth_ml,
                                                        gaynghien_v, gaynghien_l, huongthan_v, huongthan_l, matuykhac_g, matuykhac_ml,
                                                        tienchat_kg, tienchat_l, vnd, ngoaite, kimkhi, tskhac, hungkhi,
                                                        vukhi, thuocphien, CrimeId, toidanh, mucan, thang, nam, ngayxetxu, vieclam, thanhphan).value;
    } else {
        CaseId = mavuan;
        retValue = IDIS.Crime.FCrimeEditWP.ServerSideInsertCase(CaseId, vuan, ngayvuan, heroin, cansa, matuyth_g, matuyth_ml,
                                                        gaynghien_v, gaynghien_l, huongthan_v, huongthan_l, matuykhac_g, matuykhac_ml,
                                                        tienchat_kg, tienchat_l, vnd, ngoaite, kimkhi, tskhac, hungkhi,
                                                        vukhi, thuocphien, CrimeId, toidanh, mucan, thang, nam, ngayxetxu, vieclam, thanhphan).value;
    }                                     
    if (retValue.indexOf("ERROR") != -1) {
        alert(retValue);
        return;
    }
    alert(retValue);
    ShowFormInputCase();
}



